{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>注册页面</title>
	<script src="{% static 'js/jquery-1.11.3.min.js' %}"></script>
	<script src="{% static 'js/csrf.js' %}"></script>
    <script>
        $.ajaxSetup({
            data: {csrfmiddlewaretoken: '{{ csrf_token }}'}
        })
        {# $('#id_usename').blur(function () {}) jQuery监听事件的写法 #}
        {# onclick='check()' onblur='check()' 原生js的监听事件 #}
        function check() {
            {# 获取输入的用户名 #}
            var username = document.getElementById('id_username').value;
            $.ajax({
                type: 'POST',
                dataType: 'json',
                data: {'username': username},
                success: function (data, status) {
                    {#console.log(data['result']);#}
                    $('.is_use').text(data['result']);
                },
            });
        }
    </script>
</head>
<body>
	<h2>注册页面</h2>
	<p class="msg">{{ error_msg }}</p>
	<form action="/blog/register/" method="post" >
        {% csrf_token %}
		<div class="username">
		    <p>
                用户名：{{ register_form.username }}
                <span class="is_use"></span>
            </p>
		</div>
		<div class="email">
		    <p> 邮箱：{{ register_form.email }}</p>
		</div>

		<div class="password1">
		    <p> 密码：{{ register_form.password }}</p>
		</div>

		<div class="password2">
		    <p> 确认密码：{{ register_form.r_password }}</p>
		</div>
		<input id="sub" type="submit" value="提交" >
	</form>
	</body>
</html>